Skip to content

fix(sessions): Surface failed agent prompt sends to the user#2689

Merged
charlesvien merged 2 commits into
mainfrom
fix/surface-agent-prompt-send-errors
Jun 16, 2026
Merged

fix(sessions): Surface failed agent prompt sends to the user#2689
charlesvien merged 2 commits into
mainfrom
fix/surface-agent-prompt-send-errors

Conversation

@charlesvien

Copy link
Copy Markdown
Member

Problem

Button, review and skill prompts route through sendPromptToAgent, which fired the send as void (fire and forget). A rejected send (auth failure, sandbox unreachable, agent process died, dropped cloud user_message) was swallowed, so the chat showed "Generated in Xs" with no reply and no error. This is one of the paths behind reports of the agent randomly not responding on local and cloud tasks. The chat-input path already toasted these errors; the button/review/skill paths did not.

Changes

  1. AgentPromptSender port returns Promise<void> instead of void
  2. sendPromptToAgent catches rejections and shows toast.error with a generic fallback
  3. Desktop binding awaits sendPrompt so the rejection reaches the catch
  4. Add sendPromptToAgent.test.ts covering reject-with-Error, non-Error fallback and no-toast-on-success

Covered callers: CommentAnnotation, PendingReviewBar, PrCommentThread, useFixWithAgent, SkillButtonsMenu. Both local and cloud sessions throw on a failed send, so both are now surfaced.

How did you test this?

  1. vitest run on sendPromptToAgent.test.ts (3/3 pass)
  2. vitest run on packages/ui/src/features/sessions (225/225 pass, no regression)
  3. biome lint and biome format clean on the changed files
  4. Typecheck adds zero new errors (the pre-existing @posthog/quill dist errors are unrelated)

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit e021d7b.

@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
packages/ui/src/features/sessions/sendPromptToAgent.test.ts:36-58
The two rejection tests share identical structure (mock rejection → call → waitFor toast assertion) and differ only in the thrown value and expected message. Per the team's preference for parameterised tests, they can be collapsed into a single `it.each`, reducing duplication without losing coverage.

```suggestion
  it.each([
    [new Error("Agent server is not reachable"), "Agent server is not reachable"],
    ["boom", "Failed to send your message to the agent. Please try again."],
  ])(
    "surfaces rejection %s as an error toast with message %s",
    async (rejection, expectedMessage) => {
      mockSender.mockRejectedValueOnce(rejection);

      sendPromptToAgent("task-1", "hello");

      await vi.waitFor(() =>
        expect(toast.error).toHaveBeenCalledWith(expectedMessage),
      );
    },
  );
```

Reviews (1): Last reviewed commit: "surface failed agent prompt sends to the..." | Re-trigger Greptile

Comment thread packages/ui/src/features/sessions/sendPromptToAgent.test.ts Outdated
@charlesvien charlesvien added the Stamphog This will request an autostamp by stamphog on small changes label Jun 16, 2026
github-actions[bot]
github-actions Bot previously approved these changes Jun 16, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No showstoppers. The fix correctly surfaces silently-swallowed send failures via toast, the type contract change is consistent across all usages, and the new tests cover the added error paths. The bot comment is a style suggestion about parameterised tests, not a substantive concern.

@github-actions github-actions Bot dismissed their stale review June 16, 2026 05:26

New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid bug fix that surfaces silently-swallowed send errors via toast. The type contract change is consistent (one implementation, correctly updated), the catch handler is appropriate, and the new tests already use parameterised form addressing the bot's style suggestion.

@charlesvien charlesvien enabled auto-merge (squash) June 16, 2026 05:28
@charlesvien charlesvien merged commit 0d5548d into main Jun 16, 2026
23 checks passed
@charlesvien charlesvien deleted the fix/surface-agent-prompt-send-errors branch June 16, 2026 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant